﻿@{
    ViewBag.Title = "NoticeList";
    Layout = "~/Views/Shared/_LayoutChild.cshtml";
}
@using Agro.Web;
@section head {
    @if (false)
    {<script src="~/Scripts/jquery-1.6.4-vsdoc.js" type="text/javascript"></script>}
    <link href="@Url.Content("~/Content/zTreeStyle/zTreeStyle.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.ztree.all-3.0.min.js")" type="text/javascript"></script>
    @Html.Partial("_JqGrid")
    <script language="javascript" type="text/javascript">
        var selectId = "";
        var createuser = "";
        var gridId = "#tableId";
        var curruser = '@ViewBag.CurrUser';
        $(document).ready(function () {
            funGridInit();
        });
        function Search() {
            //查询
            $(gridId).setGridParam({ page: 1 });
            $(gridId).trigger("reloadGrid");
        }

        function DeleteNotice() {
            $.funListDelete(gridId, "Notice_ID", '@Url.Content("~/SystemManage/Notice/Delete_Notice")');
        }
        function editNotice(type) {
            //根据type的参数 进行设置
            var u = "/SystemManage/Notice/NoticeDetail?id=";
            if (type == "edit")
                u = "/SystemManage/Notice/NoticeDetail?id=" + selectId;
            else//如果是新增，
                createuser = curruser;
            parent.asyncbox.open({
                url: u,
                data: '',
                title: type == "add" ? "新增" : "编辑",
                width: 640,
                height: 580,
                scroll: 'no',
                modal: true,
                btnsbar: curruser == createuser ? parent.$.btn.OKCANCEL : parent.$.btn.CANCEL, //按钮栏配置请参考 “辅助函数” 中的 $.btn。
                callback: function (action) {
                    var t = this;
                    if (action == 'ok') {
                        DialogFrame($(this).attr("id")).Save(t);
                        return false;
                    }
                    if (action == 'cancel') {
                       
                    }
                    if (action == 'close') {
                       
                    }
                }
            });
        }
        function funGridInit() {
            var option = {
                height: $("#divGridContainer").height() - 51,
                width: $("#divGridContainer").width() - 2,
                url: '@Url.Content("~/SystemManage/Notice/GetNoticeList")',
                autowidth: false,
                multiselect: true,
                datatype: "json",
                sortname: 'Notice_ID',
                sortorder: 'desc',
                colModel: [
                { label: '通知标题', name: 'Notice_Title', width: 300 },
                { label: '通知内容', name: 'Notice_Content', width: 600, hidden: true },
                { label: '附件名', name: 'Notice_AttachmentName', width: 200 },
                { label: '创建时间', name: 'Notice_CreateDate', width: 100,align: 'center' },
                { hidden: true, name: 'Notice_ID' },
                { hidden: true, name: 'Notice_CreateUser' }
   	            ],
                onSelectRow: function (rowid, cellname, value, iRow, iCol) {
                    selectId = $(gridId).getCell(rowid, "Notice_ID");
                    createuser = $(gridId).getCell(rowid, "Notice_CreateUser");
                },
                ondblClickRow: function (rowid) {
                    if (rowid > 0) {
                        selectId = $(gridId).getCell(rowid, "Notice_ID");
                        editNotice('edit');   
                    }
                },
                beforeRequest: function (d) {
                }
            };
            var o = jqGridHelper.getConfig("#pageId", option);
            $(gridId).jqGrid(o);
        }
    </script>
}
<!--头部导航,不用时可以去掉-->
<div class="ui-layout-north">
    <div id="headertitle">
    </div>
    <div class="buttonlist" style="float: right; height: 34px; line-height: 36px; margin-right: 20px;">
            @Html.ButtonExt("新增", "add.png", "TZGL_ADD", "editNotice('add');")
             @Html.ButtonExt("编辑", "edit.png", "TZGL_ADD", "editNotice('edit');")
        @Html.ButtonExt("删除", "delete.png", "TZGL_DEL", "DeleteNotice();")
        
        
     @*   <a onclick="editNotice('add')" class="button green"><span class="icon-botton" style="background: url('/Content/16/add.png') no-repeat scroll 0px 4px;">
        </span>新增</a> <a onclick="editNotice('edit')" class="button green"><span class="icon-botton"
            style="background: url('/Content/16/edit.png') no-repeat scroll 0px 4px;"></span>
            编辑</a> <a onclick="DeleteNotice()" class="button green"><span class="icon-botton"
                style="background: url('/Content/16/delete.png') no-repeat scroll 0px 4px;"></span>
                删除</a> *@<a onclick="Search()" class="button green"><span class="icon-botton" style="background: url('/Content/16/search.png') no-repeat scroll 0px 4px;">
                </span>查询</a>
    </div>
</div>
<!--左侧导航，不用时直接去掉-->
<!--主窗体，页面都需要的div-->
<div id="divGridContainer" class="ui-layout-center" style="overflow: auto;">
    <table id="tableId">
    </table>
    <div id="pageId">
    </div>
</div>
